Fix enum type misinterpretation as union in record fields #663
Merged
pasindufernando1 merged 5 commits intoballerina-platform:1.5.xfrom Jan 30, 2026
Merged
Fix enum type misinterpretation as union in record fields #663pasindufernando1 merged 5 commits intoballerina-platform:1.5.xfrom
pasindufernando1 merged 5 commits intoballerina-platform:1.5.xfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes an issue where enum types were being misinterpreted as union types when used in record fields. The fix introduces logic to detect when a union type consists entirely of singleton members, which indicates it should be treated as an enum type instead.
Changes:
- Added enum detection logic in the union type processing to identify when all members are singletons
- Refactored enum type creation into a reusable
createEnumTypehelper method - Updated test data files to reflect the correct enum representation (using "members" instead of "memberTypes" and "enum" instead of "union")
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| misc/diagram-util/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/ReferenceType.java | Added singleton detection logic to differentiate enums from unions, and refactored enum creation into a helper method |
| misc/diagram-util/src/test/resources/RefTypeTest/TestData/enumSample1.json | Updated test data to use correct enum structure (members/enum) instead of union structure (memberTypes/union) |
| misc/diagram-util/src/test/resources/RefTypeTest/TestData/enumSample2.json | New test data file for validating enum type handling in records |
| misc/diagram-util/src/test/resources/RefTypeTest/BalProject7/main.bal | Added Color enum and Person2 record for testing enum field handling |
| flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/data_mapper_model/config/enum.json | Updated member names to use qualified enum notation and changed type representation from union to enum |
| flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/data_mapper_model/config/enum2.json | Updated member names to use qualified enum notation and changed type representation from union to enum |
| flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/data_mapper_custom_function/config/enum_member.json | New test configuration file for enum member handling in custom functions |
| flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/data_mapper_custom_function/source/proj4/main.bal | New test source file with function transforming optional patient data |
| flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/data_mapper_custom_function/source/proj4/Ballerina.toml | New Ballerina project configuration for test project |
| flow-model-generator/modules/flow-model-generator-ls-extension/src/test/resources/data_mapper_custom_function/source/proj4/functions.bal | Empty functions file for test project |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
LakshanWeerasinghe
approved these changes
Jan 28, 2026
Contributor
NipunaRanasinghe
left a comment
There was a problem hiding this comment.
@pasindufernando1 could you please attach the valid issue link in the PR description? current link seems to be pointing to the issues tab
nipunayf
approved these changes
Jan 29, 2026
...il/src/main/java/org/ballerinalang/diagramutil/connector/models/connector/ReferenceType.java
Outdated
Show resolved
Hide resolved
54 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
This PR fixes the issue of the inability of the enum members of a record getting treated as unions in the data-mapper backend model. Here when a union type is encountered, all its members are checked if they are singleton (which is the case of enum) and if so it is treated as a enum.
Fixes : wso2/product-ballerina-integrator#1381